package com.seocoo.worker.user.account;

import android.graphics.drawable.ColorDrawable;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.DialogFragment;
import android.support.v4.app.FragmentActivity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.Window;
import android.view.WindowManager;
import android.widget.TextView;

import com.seocoo.worker.R;
import com.seocoo.worker.base.PermissionUtil;

/***
 * 不在提现日
 */
public class NoDepositDialog extends DialogFragment implements View.OnClickListener {
    public static void showDialogUI(FragmentActivity activity, String msg) {
        NoDepositDialog dialog = new NoDepositDialog();
        dialog.showDialog(activity, msg);
    }

    String msg;

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        View view = inflater.inflate(R.layout.user_nodeposit_dialog, container, false);
        view.findViewById(R.id.iv_close).setOnClickListener(this);
        view.findViewById(R.id.tv_ok).setOnClickListener(this);
        TextView tvMsg = view.findViewById(R.id.tv_msg);
        tvMsg.setText(msg);
        return view;
    }


    @Override
    public void onActivityCreated(Bundle savedInstanceState) {
        getDialog().getWindow().requestFeature(Window.FEATURE_NO_TITLE);
        super.onActivityCreated(savedInstanceState);
        getDialog().getWindow().setBackgroundDrawable(new ColorDrawable(0x00000000));
        getDialog().getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, WindowManager.LayoutParams.MATCH_PARENT);
    }

    private void showDialog(FragmentActivity activity, String msg) {

        this.msg = msg;
        try {
            if (activity == null) {
                return;
            }
            if (isAdded()) {
                return;
            }
            super.show(activity.getSupportFragmentManager(), this.getClass().getName());
        } catch (Exception e) {
        }
    }


    @Override
    public void onClick(View v) {
        this.dismiss();
    }

    @Override
    public void dismiss() {
        FragmentActivity activity = this.getActivity();
        if (activity != null && !activity.isFinishing()) {
            this.dismissAllowingStateLoss();
        }
    }

}
